package com.plian.system.service.fr.evaluation;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.constant.sys.FormStatusConstant;

import java.util.HashMap;
import java.util.List;

import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;

/**
 * @Description:
 * @Author husong
 * @Date 2023/3/23
 **/
public interface FlowService {

    /**
     * 提交
     *
     * @param id 主键
     * @return boolean
     */
   default HashMap<String,Object> commit(String id){
       handleStatus(Long.valueOf(id), FormStatusConstant.FLOW);
       //将需要提交的流程变量返回，用于工作流侧
       return new HashMap<String, Object>();
   }

    /**
     * 审核
     *
     * @param id 主键
     * @return boolean
     */
   default Boolean finish(String id){
       return handleStatus(Long.valueOf(id), FormStatusConstant.FINISH);
   }

    /**
     * 退回
     * @param id 主键
     * @param formState
     * @return
     */
    default Boolean reject(String id, int formState,String comment){
        return handleStatus(Long.valueOf(id), formState);
    }

    /**
     * 弃审
     *
     * @param id 主键
     * @return boolean
     */
   default Boolean cancel(Long id){
       return handleStatus(Long.valueOf(id), FormStatusConstant.UNREVIEWED);
   }

    /**
     * 反审核
     * @param formId
     */
    default void goBackToStash(String formId){
        handleStatus(Long.valueOf(formId), UNREVIEWED);
    }

    Boolean handleStatus(Long id, int updateStatus);

    /**
     *
     * @param formIds
     * @return
     */
    List<PageData> findByIds(List<String> formIds);
}
